<template>
  <div id="attention">
    <div
      :class="[currentId==-3?'attention-choose attention':'attention']"
      v-show="stylesAttention.status != 0"
      @click="getGroup(-3,'attention')"
    >
      <el-avatar size="small" :src="stylesAttention.img==''?circleUrl:stylesAttention.img"></el-avatar>
      <p>{{stylesAttention.text}}</p>
      <div class="single-delete">
        <el-popover v-show="currentId==-3" placement="left" width="200" v-model="visible">
          <p>确定删除此组件吗？</p>
          <div style="text-align: right; margin: 10px 0 0">
            <el-button plain size="mini" @click="visible = false">取消</el-button>
            <el-button type="primary" size="mini" @click.stop="deleteSingle(-3)">确定</el-button>
          </div>
          <el-button type="danger" size="mini" slot="reference">删除</el-button>
        </el-popover>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState, mapMutations } from "vuex";
export default {
  name: "attention",
  data() {
    return {
      name: "",
      circleUrl:require('../../../assets/img/user.png'),
      visible:false
       
    };
  },
  computed: {
    ...mapState(["attention", "currentId", "currentName", "list"]),
    stylesAttention() {
      return this.attention[0].styles;
    },
  },
  props: ["num"],
  created() {},
  methods: {
    ...mapMutations(["getList", "getCurrenChoose", "getCurrenChooseName"]),
    deleteSingle(num) {
      this.stylesAttention.status = 0;
      this.visible = false
      if (this.list.length != 0) {
        this.getCurrenChoose(0);
        this.getCurrenChooseName(this.list[0].name + "Change");
      } else {
        this.getCurrenChoose(0);
        this.getCurrenChooseName(" ");
      }
    },
    getGroup(i, name) {
      this.getCurrenChoose(i);
      this.getCurrenChooseName(name + "Change");
    },
  },
};
</script>

<style lang="less" scoped>
@import url("../../../assets/css/base.less");
// 关注
.attention-choose {
  border: 1px solid @mainColor !important;
}
.attention {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #fff;
  padding: 5px;
  position: relative;
  border: 1px solid rgba(0,0,0,0);
  > p {
    margin-left: 10px;
  }
  > .single-delete {
    position: absolute;
    right: -65px;
    top: 0;
  }
}
</style>
